home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 117
/
FreelogNo117-OctobreNovembre2013.iso
/
Programmation
/
jedit
/
jedit5.1.0install.exe
/
{app}
/
macros
/
Emacs
/
Emacs_Previous_Line.bsh
< prev
next >
Wrap
Text File
|
2013-07-28
|
1KB
|
46 lines
/*
* Emacs_Previous_Line.bsh - Beanshell macro for jEdit that provides
* 'Emacs-like scrolling. If the caret is at the top of the
* screen the current line is centered on the screen rather than
* scrolling the whole text area by one line. For machines with
* slow painting, this can increase scrolling speed.
*
* Copyright (C) 2002-2004, Ollie Rutherfurd <oliver@rutherfurd.net>
*
* $Id: Emacs_Previous_Line.bsh 22257 2012-09-27 20:22:23Z ezust $
*/
void emacsPreviousLine(View view){
// need access to textArea.lastLinePartial
setAccessibility(true);
int first = textArea.getFirstLine();
int caretLine = textArea.getScreenLineOfOffset(textArea.getCaretPosition());
int visibleLines = textArea.getVisibleLines();
int electricScroll = textArea.getElectricScroll();
if(caretLine <= electricScroll){
int newFirst = first - ((visibleLines - electricScroll) / 2);
// if jumping would put us over the top, just go to top
if(newFirst < 0){
newFirst = 0;
}
textArea.setFirstLine(newFirst);
}
textArea.goToPrevLine(false);
}
emacsPreviousLine(view);
/*
<listitem>
<para><filename>Emacs_Previous_Line.bsh</filename></para>
<abstract><para>
Moves the cursor to the previous line, centering
the current line in the middle of the text area
if the cursor is at the top of the text area.
</para></abstract>
</listitem>
*/